home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / CAMD / examples / newexamples / timetest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-29  |  2.4 KB  |  104 lines

  1. #include <clib/alib_protos.h>
  2. #include <clib/alib_stdio_protos.h>
  3. #include <clib/cia_protos.h>
  4. #include <clib/dos_protos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/misc_protos.h>
  7. #include <clib/timer_protos.h>
  8. #include <clib/utility_protos.h>
  9.  
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. #include <midi/realtime.h>
  14. #include <midi/realtimebase.h>
  15. #include <midi/mididefs.h>
  16. #include <clib/realtime_protos.h>
  17. #include <pragmas/realtime_pragmas.h>
  18.  
  19. void kprintf(char *,...);
  20.  
  21. ULONG __saveds __asm myHookFunc (
  22. register __a1 struct pmTime *msg,
  23. register __a2 struct PlayerInfo *pi);
  24.  
  25. struct Hook myHook = {
  26.     { NULL, NULL },
  27.     myHookFunc,
  28. };
  29.  
  30. struct RealTimeBase    *RealTimeBase;
  31.  
  32. struct PlayerInfo *test_pi;
  33.  
  34. char            a_sys_ex[] = { MS_SysEx, 8, 7, 6, 5, 4, 3, 2, 1, MS_EOX };
  35. char            b_sys_ex[128];
  36.  
  37. char            r_sys_ex[] = { MS_SysEx, 0x41, 0x07, 0x14, 0x11, 0,0,0,
  38.                                 0,0,0x10, 0x70, MS_EOX };
  39.     /* stub functions */
  40.  
  41. struct PlayerInfo *CreatePlayer(Tag tag, ...)
  42. {    return CreatePlayerA((struct TagItem *)&tag );
  43. }
  44.  
  45. BOOL SetPlayerAttrs(struct PlayerInfo *pi, Tag tag, ...)
  46. {    return SetPlayerAttrsA(pi, (struct TagItem *)&tag );
  47. }
  48.  
  49. void main(int argc, char *argv[])
  50. {    LONG    time, ticks = 500;
  51.     LONG    result = 0;
  52.     ULONG    hooktag = TAG_IGNORE;
  53.     WORD    i;
  54.  
  55.     for (i=1;i<argc;i++)
  56.     {
  57.         if (argv[i][0] >= '0' && argv[i][0] <= '9') ticks = atol(argv[i]);
  58.         else if (!stricmp(argv[i],"hook")) hooktag = PLAYER_Hook;
  59.     }
  60.  
  61.     if (RealTimeBase = (struct RealTimeBase *)OpenLibrary("realtime.library",0L))
  62.     {
  63.         if (test_pi = CreatePlayer(
  64.             PLAYER_Name, "test player",
  65.             PLAYER_Conductor, "my conductor",
  66.             PLAYER_AlarmSigBit, SIGBREAKB_CTRL_F,
  67.             PLAYER_SignalTask, FindTask(NULL),
  68.             hooktag, &myHook,
  69.             TAG_DONE ))
  70.         {
  71.             printf("Opened Player!\n");
  72.  
  73.             SetConductorState(test_pi,CLOCKSTATE_RUNNING,0);
  74.  
  75.             time = RealTimeBase->Time;
  76.             SetPlayerAttrs(test_pi,
  77.                 PLAYER_AlarmTime, ticks,
  78.                 PLAYER_Ready, TRUE,
  79.                 TAG_END);
  80.  
  81.             Wait(SIGBREAKF_CTRL_F);
  82.             printf("Alarm time = %ld\n",time = RealTimeBase->Time - time);
  83.  
  84.             if (time < ticks - 50) result = 26;
  85.  
  86.             if(hooktag != TAG_IGNORE) kprintf("\n");
  87.  
  88.             DeletePlayer(test_pi);
  89.         }
  90.         CloseLibrary((struct Library *)RealTimeBase);
  91.     }
  92.  
  93.     exit(result);
  94. }
  95.  
  96. ULONG __saveds __asm myHookFunc (
  97. register __a1 struct pmTime *msg,
  98. register __a2 struct PlayerInfo *pi)
  99. {
  100.     pi->pi_MetricTime = msg->pmt_Time;
  101.     if ((pi->pi_MetricTime & 63) == 0) kprintf("%ld\r",pi->pi_MetricTime);
  102.     return 0L;
  103. }
  104.